package com.snake.springboot.authority.service.assembler;

import com.snake.springboot.authority.api.model.AuthStrategyMenuModel;
import com.snake.springboot.authority.api.request.AuthStrategyMenuSave;
import com.snake.springboot.authority.dao.mybatis.entity.AuthStrategyMenuDO;
import org.snake.common.utils.ListUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 类 {@code AuthStrategyMenuAssembler}  <br> .
 * <p>权限策略与菜单关系组装类
 * <p>创建时间：2025/02/07
 *
 * @author Huang.yj
 */
public class AuthStrategyMenuAssembler {

    public static AuthStrategyMenuDO assembleAuthStrategyMenuDO(AuthStrategyMenuModel model) {
        AuthStrategyMenuDO entity = new AuthStrategyMenuDO(model.getStrategyId(), model.getMenuId());
        entity.setMenuName(model.getMenuName());
        entity.setSystemId(model.getSystemId());
        return entity;
    }

    public static List<AuthStrategyMenuModel> assembleAuthStrategyMenuModelList(List<AuthStrategyMenuDO> entityList) {
        List<AuthStrategyMenuModel> modelList = ListUtils.copy(entityList, AuthStrategyMenuModel.class);
        return modelList;
    }

    public static List<AuthStrategyMenuDO> createAuthStrategyMenuDOList(AuthStrategyMenuSave params) {
        List<AuthStrategyMenuDO> entityList = new ArrayList<>();
        AuthStrategyMenuDO entity;
        for(String menuId :params.getMenuIds()){
            entity = new AuthStrategyMenuDO();
            entity.setStrategyId(params.getStrategyId());
            entity.setMenuId(menuId);
            entityList.add(entity);
        }
        return entityList;
    }
}
